package mini;

import java.util.HashMap;

import mini.expr.Element;

/**
 * An environment encapsulates a symbol table and a function table
 * @author Jennifer
 *
 */
public class Env {

	private HashMap<String,Element> nametable = new HashMap<String,Element>();
	private HashMap<String,Proc> functable = new HashMap<String,Proc>();
	
	public Env() {
		nametable = new HashMap<String,Element>();
		functable = new HashMap<String,Proc>();
	}
	
	public Env( HashMap<String,Element> hm, HashMap<String,Proc> ft ) {
		setNametable(hm);
		setFunctable(ft);
	}
	
	public HashMap<String, Element> getNametable() {
		return nametable;
	}
	public void setNametable(HashMap<String, Element> nametable) {
		this.nametable = nametable;
	}
	public HashMap<String, Proc> getFunctable() {
		return functable;
	}
	public void setFunctable(HashMap<String, Proc> functable) {
		this.functable = functable;
	}

	public void addToNametable(String next, Element eval) {
		if( nametable == null ) {
			nametable = new HashMap<String,Element>();
		}
		nametable.put(next,eval);
	}

	public void addToFunctiontable(String name, Proc proc) {
		if( functable == null ) {
			functable = new HashMap<String,Proc>();
		}
		functable.put(name,proc);
	}
	
}
